home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / dev / c / ExtrasLib.lha / ExtrasLib / Examples / PackedData_Test / Test.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.8 KB  |  72 lines

  1.  
  2. #include <clib/extras/packdata_protos.h>
  3. #include <proto/intuition.h>
  4. #include <proto/exec.h>
  5. #include <proto/gadtools.h>
  6. #include <proto/graphics.h>
  7. #include <proto/diskfont.h>
  8. #include <proto/dos.h>
  9. #include <stdio.h>
  10. #include <exec/memory.h>
  11. #include <stdlib.h>
  12.  
  13. #include <extras/packdata.h>
  14.  
  15. void main(void)
  16. {
  17.   struct PackedData *pd;
  18.   struct IBox box={0,0,50,50};
  19.   
  20.   LONG l,l1,l2,l3;
  21.   WORD w1;
  22.   BYTE b1,b2;
  23.   STRPTR s1,s2;
  24.   
  25.   l1=l2=l3=0;
  26.   w1=0;
  27.   b1=b2=0;
  28.   s1=s2=0;
  29.   
  30.   if(pd=PD_PackData(PD_Version, 1,
  31.                     PD_BYTE,    1,
  32.                     PD_BYTE,    0x0f,
  33.                     PD_BYTE,    0xaa,
  34.                     PD_WORD,    0x1234,
  35.                     /* begin of version 1 */
  36.                     PD_STRPTR,  "needspad",
  37.                     PD_ULONG,   0x89abcdef,
  38.                     PD_STRPTR,  "nopad",
  39.                     PD_ULONG,   0x76543210,
  40.                     PD_STRUCT(box),
  41.                     0,0))
  42.   {
  43.     for(l=0;l<pd->pd_DataSize;l++)
  44.       printf("%02x ",pd->pd_Data[l]);
  45.     printf("\n");
  46.     
  47.     PD_UnpackData(pd,
  48.                 PD_Version,   0,
  49.                 PD_BYTE,      &b1,
  50.                 PD_BYTE,      &b2,
  51.                 PD_BYTE,      0,   // set it to 0, to skip an item w/o storing it.
  52.                 PD_WORD,      &w1,
  53.                 
  54.                 PD_IfVersion, 1,   // Only proceed if PD_Version above is atleast 1  
  55.                 PD_STRPTR,    &s1,
  56.                 PD_ULONG,     &l1,
  57.                 PD_STRPTR,    &s2,
  58.                 PD_ULONG,     &l2,
  59.                 PD_STRUCT(box),
  60.                 
  61.                 0,0);
  62.     
  63.     printf("b1=%2x b2=%2x   w1=%4x   l1=%8x l2=%8x l3=%8x   s1=%20s s2=%20s\n",b1,b2,w1,l1,l2,l3,s1,s2);
  64.     printf("ibox %d %d %d %d\n",box.Left, box.Top, box.Width, box.Height);
  65.     
  66.     FreeVec(s1);
  67.     FreeVec(s2);
  68.     
  69.     PD_FreePackedData(pd);
  70.   }
  71. }
  72.